package com.toe.forum.webapi.controller;


import com.toe.common.restful.JsonResult;
import com.toe.forum.service.ForumRemarkService;
import com.toe.forum.service.ForumReplyService;
import com.toe.pojo.dto.forum.RemarkAddDTO;
import com.toe.pojo.dto.forum.ReplyAddDTO;
import com.toe.pojo.vo.forum.RemarkDetailVO;
import com.toe.pojo.vo.forum.ReplyVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 评论表 前端控制器
 * </p>
 *
 * @author 陶涛
 * @since 2022-07-19
 */
@RestController
@RequestMapping("/forum-reply")
@Api(tags = "回复模块")
public class ForumReplyController {

    @Autowired
    private ForumReplyService forumReplyService;

    @ApiOperation("添加回复一级评论")
    @PostMapping("/insert")
    public JsonResult<Void> insert(@RequestBody ReplyAddDTO replyAddDTO){
        forumReplyService.insert(replyAddDTO);
        return JsonResult.ok();
    }

    @ApiOperation("删除回复")
    @PostMapping("/delete/{id}")
    public JsonResult<Void> insert(@PathVariable long id){
        forumReplyService.delete(id);
        return JsonResult.ok();
    }

    @ApiOperation("查询回复")
    @PostMapping("/select")
    public JsonResult<List<ReplyVO>> select(long remarkId){
        List<ReplyVO> replyVOS = forumReplyService.selectReplyByRemarkId(remarkId);
        return JsonResult.ok(replyVOS);
    }

}

